package com.iss;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;

import javax.naming.spi.DirStateFactory.Result;

import com.mysql.jdbc.util.ResultSetUtil;

public class TestPreparedStatement {
	public static Student stu = new Student();

	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入用户名:");
		String uname = sc.next();
		System.out.println("请输入密码:");
		String pw = sc.next();
		Connection con = ConnectionUtil.getConnection();
		PreparedStatementUtil su = new PreparedStatementUtil();
		String sql = "select * from login where username =? and password =? ";
		PreparedStatement ps = su.getPreparedStatemen(con, sql);
		ps.setString(1, uname);
		ps.setString(2, pw);
		ResultSet rs = ResultsetUtil.getResult(ps);
		if (rs.next()) {

			System.out.println("用户名是:" + rs.getString(2) + "----" + "密码是:" + rs.getString(3));
		}
		rs.close();
		ps.close();

	}

}
